package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.StudentBean;

import com.project.mapper.IStudentMapper;
import com.project.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class StudentServiceImpl implements IStudentService {
    @Autowired
    private IStudentMapper mapper;
    @Override
    public IPage<StudentBean> findByItem(Integer pageNo, String name, String className, String room) {
        return mapper.findByItem(new Page(pageNo,5),name,className,room);
    }

    @Override
    public StudentBean findById(Integer id) {
        return mapper.findById(id);
    }

    @Override
    public void updateRoom(Integer id, Integer roomId) {
        StudentBean studentBean = new StudentBean();
        studentBean.setId(id);
        studentBean.setRoomId(roomId);
         mapper.updateById(studentBean);
    }

    @Override
    public void del(Integer id) {
         mapper.deleteById(id);
    }

    @Override
    public void add(StudentBean student) {
         mapper.insert(student);
    }
}
